package com.jie.jie.mvp.model;

import com.google.gson.Gson;
import com.jie.jie.mvp.contract.MvpContract;
import com.jie.jie.mvp.util.DataUtil;
import com.jie.jie.mvp.util.GankService;
import com.jie.jie.mvp.util.RetrofitManager;

import java.util.List;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Created by jie on 2017/1/22.
 */

public class TestModel implements MvpContract.Model{
    String type1 = "福利";
    String type2 = "Android";
    public Observable<MvpdataBean> getfuli(final int pagesize, final int page) {
        return RetrofitManager
                .getInstance()
                .createService(GankService.class)
                .getGankData(type1, pagesize, page)
                .map(new Func1<String, MvpdataBean>() {
                    @Override
                    public MvpdataBean call(String s) {
                        return new Gson().fromJson(s, MvpdataBean.class);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<MvpdataBean> getAndroid( final int pagesize, final int page) {
        return RetrofitManager
                .getInstance()
                .createService(GankService.class)
                .getGankData(type2, pagesize, page)
                .map(new Func1<String, MvpdataBean>() {
                    @Override
                    public MvpdataBean call(String s) {
                        return new Gson().fromJson(s, MvpdataBean.class);
                    }
                })
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread());
//                .observeOn(Schedulers.)
    }


}
